﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Storage;

namespace MoMoTransferVN_WP.database
{
    class DBHelper
    {
        public static string DB_PATH = Path.Combine(Path.Combine(ApplicationData.Current.LocalFolder.Path, "momoer.sqlite"));
        public static string removeAccent(string str)
        {
            string[] signs = new string[]
                {
                    "aAeEoOuUiIdDyY",
                    "áàạảãâấầậẩẫăắằặẳẵ",
                    "ÁÀẠẢÃÂẤẦẬẨẪĂẮẰẶẲẴ",
                    "éèẹẻẽêếềệểễ",
                    "ÉÈẸẺẼÊẾỀỆỂỄ",
                    "óòọỏõôốồộổỗơớờợởỡ",
                    "ÓÒỌỎÕÔỐỒỘỔỖƠỚỜỢỞỠ",
                    "úùụủũưứừựửữ",
                    "ÚÙỤỦŨƯỨỪỰỬỮ",
                    "íìịỉĩ",
                    "ÍÌỊỈĨ",
                    "đ",
                    "Đ",
                    "ýỳỵỷỹ",
                    "ÝỲỴỶỸ"
                };

            for (int i = 1; i < signs.Length; i++)
            {
                for (int j = 0; j < signs[i].Length; j++)
                {
                    str = str.Replace(signs[i][j], signs[0][i - 1]);
                }
            }
            return str.ToLower();
        }
        public static int phoneSucessful(string value)
        {
            value = value.Replace("(", "");
            value = value.Replace(")", "");
            value = value.Replace(".", "");
            value = value.Replace("+84", "0");
            value = value.Replace("+", "");
            value = value.Replace("-", "");
            value = value.Replace(" ", "");
            int number = 0;
            bool result = false;
            if ((value.Length < 10) || (value.Length > 11))
                result = false;
            else
                result = Int32.TryParse(value, out number);
            if (result)
                return number;
            else return 0;

        }
    }
}
